﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using ServiceOTO.Entity;
using ServiceOTO.Business;

namespace ServiceOTO
{
    /// <summary>
    /// Summary description for DataOut
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class DataOut : System.Web.Services.WebService
    {

        [WebMethod]
        public DataSet DanhSachXe()
        {
            OTO_ENTITY ote = new OTO_ENTITY();
            OTO_BUSSINESS otb = new OTO_BUSSINESS();
            return otb.ListXe(ote);
        }
        [WebMethod]
        public DataSet DanhSachHangXe(HANGXE_ENTITY hxEntity)
        {
            HANGXE_BUSSINESS hxBUS = new HANGXE_BUSSINESS();
            return hxBUS.ListHangXe(hxEntity);
        }
        [WebMethod]
        public DataSet HashDanhSachHangXe(HANGXE_ENTITY hxEntity)
        {
            HANGXE_BUSSINESS hxBUS = new HANGXE_BUSSINESS();
            return hxBUS.ListHangXe(hxEntity);
        }
        //public Hashtable HashDanhSachXe()
        //{
        //    OTO_ENTITY ote = new OTO_ENTITY();
        //    return otb.HashListXe(ote);
        //}
        //public Hashtable HashDanhSachXeHinh()
        //{
        //    OTO_ENTITY ote = new OTO_ENTITY();
        //    return otb.HashListXeHinh(ote);
        //}
        [WebMethod]
        public DataSet DanhSachXeTheoMaHang(string MAHANG)
        {
            OTO_ENTITY ote = new OTO_ENTITY();
            ote.MAHANG = MAHANG;
            HANGXE_BUSSINESS hxBUS = new HANGXE_BUSSINESS();
            return hxBUS.HashListXeTheoMaHang(ote);
        }
        [WebMethod]
        public DataSet DanhSachXeTrangChu()
        {
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            return otoBUS.ListXeTrangChu();
        }
        [WebMethod]
        public DataSet Web_LoadSanPhamChiTiet(string id)
        {
            OTO_ENTITY ote = new OTO_ENTITY();
            ote.MAXE = id;
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            return otoBUS.Web_ChiTietXe(ote);
        }
        [WebMethod]
        public DataSet Web_Search(string query)
        {
            OTO_ENTITY ote = new OTO_ENTITY();
            ote.TENXE = query;
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            return otoBUS.Web_SearchXe(ote);
        }
        [WebMethod]
        public bool Checklogin(string username, string password)
        {
            USER_ENTITY ut = new USER_ENTITY();
            ut.USERNAME = username;
            ut.PASSWORD = password;
            USER_BUSSINESS BUS = new USER_BUSSINESS();
            return BUS.Web_LOGIN(ut);

        }
        [WebMethod]
        public DataSet CALLENTITY(OTO_ENTITY OTE)
        {
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            return otoBUS.Web_SearchXe(OTE);
        }
        [WebMethod]
        public DataSet Web_PhanTram(string maxe)
        {
            OTO_ENTITY OTE = new OTO_ENTITY();
            OTE.MAXE = maxe;
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            return otoBUS.Web_PhanTram(OTE);
        }
        [WebMethod]
        public void Web_UPdatePhanTram(string maxe,decimal phantram)
        {
            OTO_ENTITY OTE = new OTO_ENTITY();
            OTE.MAXE = maxe;
            OTE.PHANTRAM = phantram;
            OTO_BUSSINESS otoBUS = new OTO_BUSSINESS();
            otoBUS.Web_UPDATEPT(OTE);
        }
        [WebMethod]
        public void Web_ThemDONHANG(DONHANG_ENTITY OTE)
        {
            DONHANG_BUSSINESS otoBUS = new DONHANG_BUSSINESS();
            otoBUS.ThemDONHANG(OTE);
        }
        [WebMethod]
        public void Web_ThemDONHANGCT(CHITIET_DONHANG_ENTITY OTE)
        {
            DONHANG_BUSSINESS otoBUS = new DONHANG_BUSSINESS();
            otoBUS.ThemDONHANGDETAIL(OTE);
        }
        [WebMethod]
        public Int32 Web_ThemKH(KHACHHANG_ENTITY OTE)
        {
            KHACHANG_BUSSINESS otoBUS = new KHACHANG_BUSSINESS();
            return otoBUS.THEMKH(OTE);
        }
        //[WebMethod]
        //public DataSet TONKHO(string maxe)
        //{
        //    PHIEUNHAP_BUSSINESS ctpnBus = new PHIEUNHAP_BUSSINESS();
        //    //return ctpnBus.TONKHO(maxe);
        //}
        [WebMethod]
        public DataSet DONGIA(string maxe)
        {
            PHIEUNHAP_BUSSINESS ctpnBus = new PHIEUNHAP_BUSSINESS();
            return ctpnBus.Web_LoadGia(maxe);
        }
    }
}
